    $(function () {
        var mstr = window.location.search;
        var member_id = mstr.substring(mstr.indexOf("=")+1);
        console.log(member_id);

        // 查询收货人
        data = {
            memberId: member_id
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var json = data.consignee;
                var optionstring = "<option value=\"\" selected style=\"display:none;\">请选择授权收货人</option>";
                for (var i = 0; i < json.length; i++) {
                    optionstring += "<option>"+json[i].consignee_single_name+"</option>"
                }
                $("#linkman").html(optionstring);
            }
        }
        web.doAjax(root.condata.adminQueryMemberShipPerson, 'post', data, succCallBack);

        // 查询收货区域
        add_data = {
            level: 101,
            memberId: member_id
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var json = data.list;
                var optionstring = "<option>省</option>";
                for (var i = 0; i < json.length; i++) {
                    optionstring += "<option value='"+json[i].address_id+"'>"+json[i].name+"</option>";
                }
                $(".province").html(optionstring);
            }
        }
        web.doAjax(root.condata.adminGetAddByParam, 'post', add_data, succCallBack);
    });

    // 获取市
    function getCity(val, level) {
        var mstr = window.location.search;
        var member_id = mstr.substring(mstr.indexOf("=")+1);

        $(".city").html("<option>市</option>");
        $(".district").html("<option>区/县</option>");
        $(".town").html("<option>镇</option>");

        console.log(val);
        add_data = {
            level: level,
            parentCode: val,
            memberId: member_id
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var json = data.list;
                var optionstring = "<option>市</option>";
                for (var i = 0; i < json.length; i++) {
                    optionstring += "<option value='"+json[i].address_id+"'>"+json[i].name+"</option>";
                }
                $(".city").html(optionstring);
            }
        }
        web.doAjax(root.condata.adminGetAddByParam, 'post', add_data, succCallBack);
    }

    // 获取区、县
    function getArea(val, level) {
        var mstr = window.location.search;
        var member_id = mstr.substring(mstr.indexOf("=")+1);

        $(".district").html("<option>区/县</option>");
        $(".town").html("<option>镇</option>");

        console.log(val);
        add_data = {
            level: level,
            parentCode: val,
            memberId: member_id
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var json = data.list;
                var optionstring = "<option>区/县</option>";
                for (var i = 0; i < json.length; i++) {
                    optionstring += "<option value='"+json[i].address_id+"'>"+json[i].name+"</option>";
                }
                $(".district").html(optionstring);
            }
        }
        web.doAjax(root.condata.adminGetAddByParam, 'post', add_data, succCallBack);
    }

    // 获取镇
    function getTown(val, level) {
        var mstr = window.location.search;
        var member_id = mstr.substring(mstr.indexOf("=")+1);

        $(".town").html("<option>镇</option>");

        console.log(val);
        add_data = {
            level: level,
            parentCode: val,
            memberId: member_id
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if (data.errorCode == "1") {
                var json = data.list;
                var optionstring = "<option>镇</option>";
                for (var i = 0; i < json.length; i++) {
                    optionstring += "<option value='"+json[i].address_id+"'>"+json[i].name+"</option>";
                }
                $(".town").html(optionstring);
            }
        }
        web.doAjax(root.condata.adminGetAddByParam, 'post', add_data, succCallBack);
    }

    // 提交数据
    function saveAddress() {
        var mstr = window.location.search;
        var member_id = mstr.substring(mstr.indexOf("=")+1);
        console.log(member_id);

        var detail_address = $("#detailedAddress").val();
        var add_alias = $("#addAlias").val();
        var linkman = $("#linkman").val();
        var celephone = $("#celephone").val();
        var landlineCelephone = $("#landlineCelephone").val();
        var email = $("#email").val();

        var province_id = $(".province").val();
        var city_id = $(".city").val();
        var district_id = $(".district").val();
        var stree_id = $(".town").val();

        add_data = {
            provinceId: province_id,
            cityId: city_id,
            districtId: district_id,
            streetId: stree_id,
            detailAddress: detail_address,
            linkman: linkman,
            mobile: celephone,
            addAlias: add_alias,
            officePhone: landlineCelephone,
            email: email,
            memberId: member_id
        }
        console.log(add_data);
        var succCallBack = function (data, status, response) {
            console.log(data);
            if (data.errorCode == "1") {
                console.log("添加地址成功");
                var index =  parent.location.reload();
                parent.layer.close(index);

            } else {
                console.log("添加地址失败");
            }
        }
        web.doAjax(root.condata.adminAddMemberShoppingAddress, 'post', add_data, succCallBack);
    }

    /*校验电话码格式 */
    function isTelCode(str) {
        var reg= /^1[34578]\d{9}$/;
        console.log(reg.test(str));
        if (!reg.test(str)) {
            layer.msg('请输入正确的手机号码', {icon: 6,time:1500});
        }
    }

    /*校验固定电话码格式 */
    function isPhoneCode(str) {
        var reg= /^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
        console.log(reg.test(str));
        if (!reg.test(str)) {
            layer.msg('请输入正确的固定电话', {icon: 6,time:1500});
        }
    }

    /*校验邮件地址是否合法 */
    function isEmail(str) {
        var reg=/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
        if (!reg.test(str)) {
            layer.msg('请输入正确的邮箱地址', {icon: 6,time:1500});
        } else {
            console.log('正确的邮箱');
        }
    }